package com.ibeeking.found.report.service.common.constant;

public enum ErrorCode {
    f4OK(100, "操作成功"),
    FAIL(101, "操作失败"),
    ALERT(102, "alert"),
    ERROR(5000, "error");

    private int code;
    private String message;

    ErrorCode(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public static ErrorCode getResultEnum(int code) {
        ErrorCode[] values = values();
        for (ErrorCode errorCode : values) {
            if (errorCode.getCode() == code) {
                return errorCode;
            }
        }
        return ERROR;
    }

    public static ErrorCode getResultEnum(String message) {
        ErrorCode[] values = values();
        for (ErrorCode errorCode : values) {
            if (errorCode.getMessage().equals(message)) {
                return errorCode;
            }
        }
        return ERROR;
    }

    public int getCode() {
        return this.code;
    }

    public String getMessage() {
        return this.message;
    }
}
